;;; init-func.el -*- lexical-binding: t; -*-

;; taken from Spacemacs: https://github.com/syl20bnr/spacemacs
(defun canary/toggle-fullscreen ()
  "Toggle full screen on X11 and Carbon"
  (interactive)
  (cond
   ((eq window-system 'x)
    (set-frame-parameter nil 'fullscreen
                         (when (not (frame-parameter nil 'fullscreen))
                           'fullboth)))
   ((eq window-system 'mac)
    (set-frame-parameter
     nil 'fullscreen
     (when (not (frame-parameter nil 'fullscreen)) 'fullscreen)))))

(defun canary/join-dirs (root &rest dirs)
  (apply 'concat (mapcar (lambda (name)
                           (file-name-as-directory name))
                         (push root dirs))))


(defun canary/standardize-theme (theme)
  "Translate theme name to actual THEME package."
  (pcase theme
    ('dark 'doom-one)
    ('light 'doom-one-light)
    ('citylights 'doom-city-lights)
    ('solarlight 'doom-solarized-light)
    ('yang 'tao-yang)
    ('yin 'tao-yin)
    (_ theme)))

(defun canary/is-doom-theme-p (theme)
  "Check whether the THEME is a doom theme. THEME is a symbol."
  (string-prefix-p "doom" (symbol-name (canary/standardize-theme theme))))
(defun canary/is-tao-theme-p (theme)
  "Check whether the THEME is a tao theme. THEME is a symbol."
  (string-prefix-p "tao" (symbol-name (canary/standardize-theme theme))))

(defun canary/load-theme (theme)
  "Set color THEME."
  (interactive
   (list
    (intern (completing-read "Load theme: "
                             '(dark light citylights solarlight yang yin)))))
  (let ((theme (canary/standardize-theme theme)))
    (mapc #'disable-theme custom-enabled-themes)
    (load-theme theme t)))

(provide 'init-func)
